<template>
  <div class='records first-box'>
    <Search :searchFun="getSearch"></Search>
    <GreyLine></GreyLine>
    <Scroll :hasmore="hasmore" :pullup="pullup" setHeight="-60">
      <List :data="listData"></List>
    </Scroll>
  </div>
</template>
<script>
import Search from '../../../common/search'
import GreyLine from '../../../common/line.vue'
import Scroll from '../../../common/scroller'
import List from './list'
export default {
  components: {Search,GreyLine,Scroll,List},
  name: "",
  data() {
    return {
      hasmore:false,
      pageInfo:{
        page:1,
      },
      keywords:"",
      listData:[
        // {
        //   id:1,
        //   type:"保养",
        //   date:"2018-5-12",
        //   content:"意见反馈内容意见反馈内容意见反馈内容意见反馈内容意见反馈内容意见反馈内容意见反馈内容意见反馈内容.",
        //   answertime:"2018-5-20",
        //   answercontent:"感谢您的反馈，我们工作人员会在3个工作日内为您妥善解决，祝您生活愉快",
        // }
      ]
    };
  },
  methods: {
    getSearch(search){
      this.keywords=search
      // console.log("click----search",search)
      this.pageInfo.page=1
      this.listData=[]
      this.getList()
      bus.$emit("resetScroller")
    },

    // 下拉刷新方法回调
    pullup(func){
      if(this.hasmore){
        this.pageInfo.page++
         _g.orderList([this.getList,func])
         return
      }
      // console.log("发请求了") 
      // func()
    },
    getList(){
      var params={
        userId:sessionStorage.getItem("userId"),
        currentPage:this.pageInfo.page,
        pageSize:10,
        word:this.keywords,
      }
      _g.apiPost("vipFeedback/selectList.do",params).then(res=>{
        this.hasmore=res.data.hasNextPage
        
        var goal=[]
        res.data.list.forEach(ele => {
          goal.push({
            id:ele.id,
            type:ele.feedbackType,
            content:ele.feedbackContent,
            date:ele.feedbackTime?_g.formatTime(ele.feedbackTime):"",
            answertime:ele.recoveryTime?_g.feedbackTime(ele.recoveryTime):"",
            answercontent:ele.replyContent||"感谢您的反馈，我们工作人员会在3个工作日内为您妥善解决，祝您生活愉快"
          })
        });
        this.$set(this,"listData",this.listData.concat(goal))
      })
    }
  },
  created() {
    this.getList()
  }
};
</script>
<style lang="scss" scoped>
.records {
}
</style>